package com.dycc.libary.view.guid;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.dycc.libary.util.ScreenUtils;

import java.lang.ref.WeakReference;

/**
 * 用户引导管理
 * Created by wxk on 2018/2/2 0002.
 */
public class GuideViewManager {
    private FrameLayout mParentView;
    public static final String TAG = "show_guid";
    private boolean mEveryWhereTouchable;
    /**
     * 检测当前guid是否已显示
     */
    public String guid_tag;

    private WeakReference<Activity> activity;
    private GuideView guideView;

    public GuideViewManager(Activity activity, String guid_tag) {
        this.activity = new WeakReference<>(activity);
        this.guideView = new GuideView(activity);
        this.guid_tag = guid_tag;
    }

    /**
     * 设置高亮区域形状
     * @param style  GuideView.VIEWSTYLE_RECT = 0;GuideView.VIEWSTYLE_CIRCLE = 1;GuideView.VIEWSTYLE_OVAL = 2;
     * @return
     */
    public GuideViewManager setHighLightStyle(int style) {
        guideView.setHighLightStyle(style);
        return this;

    }

    /**
     * 设置边缘线条类型
     * @param blurStyle MASKBLURSTYLE_SOLID = 0   MASKBLURSTYLE_NORMAL = 1
     * @return
     */
    public GuideViewManager setMaskblurstyle(int blurStyle) {
        guideView.setMaskblurstyle(blurStyle);
        return this;
    }

    public GuideViewManager setTipView(int resId) {
        guideView.setTipView(resId);
        return this;
    }

    public GuideViewManager setTipView(View view,int width,int height) {
        guideView.setTipView(view,width,height);
        return this;
    }

    public void show(View... views) {
        mParentView = (FrameLayout) activity.get().getWindow().getDecorView();
        int paddingTop = ScreenUtils.getStatusBarHeight(activity.get());
        guideView.setPadding(0, paddingTop, 0, 0);
        mParentView.addView(guideView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams
                .MATCH_PARENT));
        guideView.setHightLightView(views);
    }

    public GuideViewManager setTouchOutsideDismiss(boolean flag) {
        guideView.setTouchOutsideDismiss(flag);
        return this;
    }

}
